/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dpoo.figuras;

import dpoo.control.Control;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.border.Border;

/**
 *
 * @author david
 */
public class FiguraClase extends JComponent implements MouseListener, MouseMotionListener {
    
    private int x,y,w,h;
    private String nombre;
    private int visibilidad;
    private boolean modAbstracta;
    private boolean modFinal;
    
    
    public FiguraClase(int x, int y) {
        
        this.x = x;
        this.y = y;
        this.w = 100;
        this.h = 70;
        
        this.nombre = "Nueva clase";
        this.visibilidad = 0;
        this.modAbstracta = false;
        this.modFinal = false;
        
        this.setBounds(this.x, this.y, this.w, this.h);
        this.addMouseListener(this); 
        this.addMouseMotionListener(this);
        

    }

    public void paint(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
                Border blackline;
        
        g2.setColor(new Color(255,255,153));
        g2.fillRect(0, 0, this.w-1, this.h-1);
        g2.setColor(Color.BLACK);        
        //g2.draw(new Rectangle2D.Double(0, 0, this.w-1, this.h-1));
        g2.draw(new Rectangle2D.Double(0, 20, this.w-1, 20));
        
        blackline = BorderFactory.createLineBorder(Color.GREEN);
        this.setBorder(blackline);
    }
    
    
    //MÉTODOS PARA DEVOLVER INFORMACIÓN DE LA CLASE
    public String getNombre() {
        return this.nombre;
    }
    
    public int getVisibilidad() {
        return this.visibilidad;
    }
    
    public boolean getModAbstracta() {
        return this.modAbstracta;
    }
    
    public boolean getModFinal() {
        return this.modFinal;
    }
    
    
    //MÉTODOS PARA MANIPULAR INFORMACIÓN DE LA CLASE
    public void setNombre(String nombre) {
        this.nombre = nombre;
    }
    
    public void setVisiblidad(int visibilidad) {
        if((visibilidad >= 0) && (visibilidad <= 4))
            this.visibilidad = visibilidad;
    }
    
    public void setModAbstracta(boolean modAbstracta) {
        this.modAbstracta = modAbstracta;
    }
    
    public void setModFinal(boolean modFinal) {
        this.modFinal = modFinal;
    }
    
    public void mousePressed(MouseEvent event) {
	//código de la función respuesta
    }

    public void mouseExited(MouseEvent event) {}
    public void mouseReleased(MouseEvent event) {}
    public void mouseClicked(MouseEvent event) {}
    public void mouseEntered(MouseEvent event) {}

 //funciones del interface MouseMotionListener
    public void mouseDragged(MouseEvent event) {
        this.setBounds(this.getX()+event.getX(),this.getY()+event.getY(),this.getWidth(),this.getHeight());
    }
    public void mouseMoved(MouseEvent event) {}  
}
